<!doctype html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>绿色版Solr安装配置 | Mike SU</title>
<meta property="og:title" content="绿色版Solr安装配置 - Mike SU">
<meta property="og:type" content="article">
	
<meta property="article:published_time" content='2014-10-30T17:52:30&#43;08:00'>
	
	
<meta property="article:modified_time" content='2014-10-30T17:52:30&#43;08:00'>
	
<meta name="Keywords" content="">
<meta name="description" content="绿色版Solr安装配置">
	
<meta name="author" content="Mike SU">
<meta property="og:url" content="https://mikesu.net/29/">
	
	<link rel="shortcut icon" href='/favicon.ico'  type="image/x-icon">
	<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/normalize.css/normalize.min.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/purecss/build/pure-min.min.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/purecss/build/grids-responsive-min.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">

<link rel="stylesheet" href="/css/style.min.css">
	
</head>
<body>
    <div class="body_container">
		<header id="header">
			<div class="site-name ">
	
	<a id="logo" href="/">Mike SU</a>
	<p class="description">Note &amp; Blog</p>
</div>
		    <nav id="nav-menu">
	<a class="" href="/">
		<i class="fa fa-home"> 首页</i>
	</a>
	
	<a  href="/archives/" title="归档">
		<i class='fa fa-archive'></i> 归档
	</a>
	
	<a  href="/about/" title="关于">
		<i class='fa fa-user'></i> 关于
	</a>
	
</nav>
		</header>
        <div id="layout" class="pure-g">
            <div class="pure-u-1 pure-u-md-3-4">
				<main class="content_container">
					
<article class="post">
	

	<h1 class="post-title">绿色版Solr安装配置</h1>
	<div class="post-meta">
	2014年10月30日
	
	</div>
	<div class="post-content">
		<p>  由于Solr可以用Tomcat运行的，而Tomcat是用JDK运行的，可以利用JDK免安装的特点实现Solr的免安装。就是通过配置整合JDK、Tomcat、Solr，实现一次配置好后，打包成tar包，就可以方便在其他服务器部署。</p>
<h3 id="前期准备">前期准备</h3>
<p>  先到网上下载好jdk,tomcat,solr。下面使用jdk-7u45-linux-x64.tar.gz, apache-tomcat-7.0.42.tar.gz, solr-4.5.0.tgz进行介绍。</p>
<p>解压下载的文件</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback"># tar xzvf jdk-7u45-linux-x64.tar.gz
# tar xzvf apache-tomcat-7.0.42.tar.gz
# tar xzvf solr-4.5.0.tgz
</code></pre></div><h3 id="直接采用tomcat的目录结构最终整合的目录solr">直接采用tomcat的目录结构最终整合的目录solr</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback"># mv apache-tomcat-7.0.42 solr
</code></pre></div><h3 id="把jdk移动到solr目录">把JDK移动到solr目录</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback"># mv jdk1.7.0_45 solr/jdk
</code></pre></div><h3 id="拷贝solr的war包到webapps目录">拷贝solr的war包到webapps目录</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback"># cp solr-4.5.0/dist/solr-4.5.0.war solr/webapps/solr.war
</code></pre></div><h3 id="配置solr的日志依赖lib和配置文件log4jproperties">配置Solr的日志依赖lib和配置文件log4j.properties</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback"># cp solr-4.5.0/example/lib/ext/* solr/lib/
# cp solr-4.5.0/example/resources/log4j.properties solr/lib/
</code></pre></div><h3 id="创建solr-home目录并配置solrxml">创建solr home目录并配置solr.xml</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback"># mkdir solr/cores
# cp solr-4.5.0/example/solr/solr.xml solr/cores
</code></pre></div><h3 id="修改启动脚本">修改启动脚本</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback"># nano solr/bin/startup.sh
</code></pre></div><p>把以下代码加到startup.sh里面的#!/bin/sh下面</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh"><span style="color:#069;font-weight:bold">if</span> <span style="color:#366">test</span> <span style="color:#a00">${</span><span style="color:#033">0</span>:<span style="color:#033">0</span>:<span style="color:#033">1</span><span style="color:#a00">}</span> <span style="color:#555">=</span> <span style="color:#c30">&#39;/&#39;</span>
<span style="color:#069;font-weight:bold">then</span>
    <span style="color:#033">ABS_PATH</span><span style="color:#555">=</span><span style="color:#c30">`</span>dirname <span style="color:#033">$0</span><span style="color:#c30">`</span>/..
<span style="color:#069;font-weight:bold">else</span>
    <span style="color:#033">ABS_PATH</span><span style="color:#555">=</span><span style="color:#c30">`</span><span style="color:#366">pwd</span><span style="color:#c30">`</span>/<span style="color:#c30">`</span>dirname <span style="color:#033">$0</span><span style="color:#c30">`</span>/..
<span style="color:#069;font-weight:bold">fi</span>
<span style="color:#366">export</span> <span style="color:#033">JAVA_HOME</span><span style="color:#555">=</span><span style="color:#033">$ABS_PATH</span>/jdk
<span style="color:#366">export</span> <span style="color:#033">PATH</span><span style="color:#555">=</span><span style="color:#033">$JAVA_HOME</span>/bin:<span style="color:#033">$PATH</span>
<span style="color:#366">export</span> <span style="color:#033">CLASSPATH</span><span style="color:#555">=</span><span style="color:#033">$JAVA_HOME</span>/lib:<span style="color:#033">$CLASSPATH</span>
<span style="color:#366">export</span> <span style="color:#033">JAVA_OPTS</span><span style="color:#555">=</span><span style="color:#c30">&#34;</span><span style="color:#033">$JAVA_OPTS</span><span style="color:#c30"> -Dsolr.solr.home=</span><span style="color:#033">$ABS_PATH</span><span style="color:#c30">/cores/ -Dsolr.log=</span><span style="color:#033">$ABS_PATH</span><span style="color:#c30">/logs/&#34;</span>
</code></pre></div><h3 id="修改tomcat的serverxml">修改tomcat的server.xml</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback"># nano solr/conf/server.xml
</code></pre></div><p>找到</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#309;font-weight:bold">&lt;Connector</span> <span style="color:#309">port=</span><span style="color:#c30">&#34;8080&#34;</span> <span style="color:#309">protocol=</span><span style="color:#c30">&#34;HTTP/1.1&#34;</span>
           <span style="color:#309">connectionTimeout=</span><span style="color:#c30">&#34;20000&#34;</span>
           <span style="color:#309">redirectPort=</span><span style="color:#c30">&#34;8443&#34;</span><span style="color:#309;font-weight:bold">/&gt;</span>
</code></pre></div><p>修改为</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#309;font-weight:bold">&lt;Connector</span> <span style="color:#309">port=</span><span style="color:#c30">&#34;8080&#34;</span> <span style="color:#309">protocol=</span><span style="color:#c30">&#34;HTTP/1.1&#34;</span>
           <span style="color:#309">connectionTimeout=</span><span style="color:#c30">&#34;20000&#34;</span>
           <span style="color:#309">redirectPort=</span><span style="color:#c30">&#34;8443&#34;</span> <span style="color:#309">URIEncoding=</span><span style="color:#c30">&#34;UTF-8&#34;</span><span style="color:#309;font-weight:bold">/&gt;</span>
</code></pre></div><p>到此所有配置已经完成，通过启动脚本启动solr。访问 http://[server ip]:8080/solr 测试是否配置成功。</p>

	</div>
	
	
<div class="post-nav">
	
	
	<a class="pre" href="/28/">我的博客之路</a>
	
	
	
	
	<a class="next" href="/30/">Boot2docker通过VirtualBox Guest Additions实现目录共享</a>
	
	
</div>

	
<div class="post-archive">
    <ul class="post-copyright">
        <li><strong>原文作者：</strong><a rel="author" href="https://mikesu.net">Mike SU</a></li>
        <li style="word-break:break-all"><strong>原文链接：</strong><a href="https://mikesu.net/29/">https://mikesu.net/29/</a></li>
        <li><strong>版权声明：</strong>本作品采用<a rel="license" href="https://creativecommons.org/licenses/by/4.0/">署名 4.0 国际 (CC BY 4.0)</a>进行许可。</li>
    </ul>
</div>
<br/>


	

	
    

    
    
</article>

				</main>
            </div>
			<div class="pure-u-1-4 hidden_mid_and_down">
			    <div id="sidebar">
				    <section class="widget">
<form class="search-form" action='/search/' method="get" accept-charset="utf-8" _lpchecked="1">
      
      <input type="text" name="q" maxlength="20" placeholder="Search">
	  
</form>
</section>
					
					<section class="widget">
<h3 class="widget-title"><i class="fa fa-file-o"> 最近文章</i></h3>
<ul class="widget-list">
    
    <li>
        <a href="/35/" title="搭建 JavaScript 开发环境">搭建 JavaScript 开发环境</a>
    </li>
    
    <li>
        <a href="/34/" title="Java RMI远程调用简单示例">Java RMI远程调用简单示例</a>
    </li>
    
    <li>
        <a href="/33/" title="通过WebRTC实现网页间文件传输">通过WebRTC实现网页间文件传输</a>
    </li>
    
    <li>
        <a href="/32/" title="Boot2docker通过Samba实现文件夹共享">Boot2docker通过Samba实现文件夹共享</a>
    </li>
    
    <li>
        <a href="/31/" title="docker 使用代理连接 Docker Hub">docker 使用代理连接 Docker Hub</a>
    </li>
    
    <li>
        <a href="/30/" title="Boot2docker通过VirtualBox Guest Additions实现目录共享">Boot2docker通过VirtualBox Guest Additions实现目录共享</a>
    </li>
    
    <li>
        <a href="/29/" title="绿色版Solr安装配置">绿色版Solr安装配置</a>
    </li>
    
    <li>
        <a href="/28/" title="我的博客之路">我的博客之路</a>
    </li>
    
    <li>
        <a href="/27/" title="Pelican支持Swiftype搜索">Pelican支持Swiftype搜索</a>
    </li>
    
    <li>
        <a href="/26/" title="启用免费版MarkdownPad2的Markdown扩展模式">启用免费版MarkdownPad2的Markdown扩展模式</a>
    </li>
    
</ul>
</section>
					
					
				</div>
			</div>
			<div class="pure-u-1 pure-u-md-3-4">
				<footer id="footer">
					<div>
	Copyright &copy; 2021 <a href="https://mikesu.net">Mike SU</a>
	
</div>
<div>
	Powered by<a href="https://gohugo.io/" target="_black" rel="nofollow"> Hugo</a>
	Theme by<a href="https://github.com/tufu9441/maupassant-hexo" target="_black"> Maupassant</a>
</div>
<a id="rocket" href="#top"></a>
					<script type="text/javascript" src="//cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="/js/totop.js"></script>

					
	<script type="text/javascript" src="/js/toc.js"></script>

				</footer>
			</div>
        </div>
    </div>
</body>
</html>